package com.leruan.aasimp.constant;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.leruan.aasimp.bean.UsedCarSortBean;

public class UsedCarConstant {

    public static List<UsedCarSortBean> usedCarSortList = new ArrayList<UsedCarSortBean>();
    public static List<String> priceList = new ArrayList<String>();
    public static List<String> carYearList = new ArrayList<String>();

    public static List<String> carBuyAddress = new ArrayList<String>();

    public static final int PAGE_SIZE = 10;
    public static final int PAGE_SIZE_2 = 20;
    public static final int PAGE_SIZE_3 = 8;
    

    static {
        initSortList();
        initPriceList();
        initCarYearList();
        initCarBuyAddress();
    }


    public static void initSortList() {
        UsedCarSortBean usedCarSortBean = new UsedCarSortBean();
        List<String> department = new ArrayList<String>();
        usedCarSortBean.setBrand("大众");
        department.add("捷达");
        department.add("帕萨特");
        department.add("桑塔纳");
        department.add("新宝来");
        department.add("桑塔纳2000");
        department.add("POLO");
        department.add("速腾");
        department.add("高尔夫");
        department.add("桑塔纳3000");
        department.add("迈腾");
        department.add("朗逸");
        department.add("高尔");
        usedCarSortBean.setDepartment(department);
        usedCarSortList.add(usedCarSortBean);
        usedCarSortBean = new UsedCarSortBean();
        usedCarSortBean.setBrand("本田");
        department = new ArrayList<String>();
        department.add("雅阁");
        department.add("飞度");
        usedCarSortBean = new UsedCarSortBean();
        usedCarSortList.add(usedCarSortBean);
    }

    public static void initPriceList() {
        priceList.add("1万元以内");
        priceList.add("1-2万");
        priceList.add("2-3万");
        priceList.add("3-5万");
        priceList.add("5-8万");
        priceList.add("8-12万");
        priceList.add("12-18万");
        priceList.add("18-24万");
        priceList.add("24-40万");
        priceList.add("40万以上");
    }

    private static void initCarYearList() {
        carYearList.add("1年以内");
        carYearList.add("1-3年");
        carYearList.add("3-5年");
        carYearList.add("5-8年");
        carYearList.add("8-10年");
        carYearList.add("10年以上");
    }

    private static void initCarBuyAddress() {
        carBuyAddress.add("西湖");
        carBuyAddress.add("拱墅");
        carBuyAddress.add("江干");
        carBuyAddress.add("上城");
        carBuyAddress.add("下城");
        carBuyAddress.add("余杭");
        carBuyAddress.add("萧山");
        carBuyAddress.add("滨江");
        carBuyAddress.add("建德");
        carBuyAddress.add("富阳");
        carBuyAddress.add("临安");
        carBuyAddress.add("桐庐");
        carBuyAddress.add("淳安");
        carBuyAddress.add("杭州周边");
    }

	public static Map<String, Object> convertPrice(Map<String, Object> map,
			String price) {
		if("1万元以内".equals(price)){
			map.put("endPrice", 1);
		}else if("1-2万".equals(price)){
			map.put("startPrice", 1);
			map.put("endPrice", 2);
		}else if("2-3万".equals(price)){
			map.put("startPrice", 2);
			map.put("endPrice", 3);
		}else if("3-5万".equals(price)){
			map.put("startPrice", 3);
			map.put("endPrice", 5);
		}else if("5-8万".equals(price)){
			map.put("startPrice", 5);
			map.put("endPrice", 8);
		}else if("8-12万".equals(price)){
			map.put("startPrice", 8);
			map.put("endPrice", 12);
		}else if("12-18万".equals(price)){
			map.put("startPrice", 12);
			map.put("endPrice", 18);
		}else if("18-24万".equals(price)){
			map.put("startPrice", 18);
			map.put("endPrice", 24);
		}else if("24-40万".equals(price)){
			map.put("startPrice", 8);
			map.put("endPrice", 12);
		}else if("40万以上".equals(price)){
			map.put("startPrice", 40);
		}
		return map;
	}
	
	public static Map<String, Object> convertPrice_2(Map<String, Object> map,
			String price) {
		if("1万元以内".equals(price))
			map.put("price", 0);
		else if("1-2万".equals(price))
			map.put("price", 1);
		else if("2-3万".equals(price))
			map.put("price", 2);
		else if("3-5万".equals(price))
			map.put("price", 3);
		else if("5-8万".equals(price))
			map.put("price", 4);
		else if("8-12万".equals(price))
			map.put("price", 5);
		else if("12-18万".equals(price))
			map.put("price", 6);
		else if("18-24万".equals(price))
			map.put("price", 7);
		else if("24-40万".equals(price))
			map.put("price", 8);
		else if("40万以上".equals(price))
			map.put("price", 9);
		return  map;
	}
	
	public static Map<String, Object> convertCarYear(Map<String, Object> map,
			String carYear) {
		
		if("1年以内".equals(carYear)){
			map.put("endcarYear", getDate(1));
		}else if("1-3年".equals(carYear)){
			map.put("startCarYear", getDate(1));
			map.put("endCarYear", getDate(3));
		}else if("3-5年".equals(carYear)){
			map.put("startCarYear", getDate(3));
			map.put("endCarYear", getDate(5));
		}else if("5-8年".equals(carYear)){
			map.put("startCarYear", getDate(5));
			map.put("endCarYear", getDate(8));
		}else if("8-10年".equals(carYear)){
			map.put("startCarYear", getDate(8));
			map.put("endCarYear", getDate(10));
		}else if("10年以上".equals(carYear)){
			map.put("startCarYear", getDate(10));
		}
			
		return map;
	}
	
	public static Date getDate(int year){
		Calendar curr = Calendar.getInstance();
		curr.set(Calendar.YEAR,curr.get(Calendar.YEAR) - year);
		Date date=curr.getTime();
		return date;
	}

}
